<include file="Common:header"/>

<body>
	<div class="bannerbaowei">
		<div class="dajianxi"></div>
		<!-- <div class="leftone" onclick="debug('此功能调试中')"><font color="white">实时数据</font></div>
		<div class="lefttwo" onclick="debug('此功能调试中')">日统计</font></div> -->
		<div class="tit1h4391">我的发布：</div>
	</div>
	<div class="page">
		<div class="main">
			<foreach name="article_list" item="value">
				<div class="txt1">
					<div class="pa5anr"><small  class="smallone"><{:date("Y-m-d H:i:s",$value['createtime'])}></small></div>
					<div class="pa5h4"style=" height: 15px;"><{$value['title']}></div>
					<div class="anniu">
						<font color="#fff">
							<b><a href="<{:U('Home/Article/article_detail',array('aid'=>$value['id']))}>" style="color:#ffffff">修改</a></b>
						</font>
					</div>
					<div class="anniu">
						<font color="#fff">
							<b>
								<a href="javascript:void(0)" data-aid="<{$value['id']}>" onclick="delete_article(this)" style="color:#ffffff">删除</a>
							</b>
						</font>
					</div>
				</div>
				<hr class="hrrr"/>
			</foreach>
		<div id="loadding"></div>
		<div style="height:50px"></div>
		</div><!--main-->
	</div><!--page-->
	<input type="hidden" id="page" value="1">
	<include file="Common:menu"/>
</body>
</html>
<script>

$(function(){
	$(window).scroll(function () {
		if($(window).scrollTop()>=($(document).height()-$(window).height())){
			ajax_article();
		}
	});
});

//加载文章
function ajax_article(){
	var page = $('#page').val();
	if(page == '-1'){
		return false;
	}
	//加载进度条
	layer.open({
		type: 2,
		content: '加载中'
	});
	$.ajax({
		type: "POST",
		url: "<{:U('Home/Article/article_list')}>",
		data: "page="+page,
		dataType:'json',
		success: function(msg){
			if(msg.status == '1'){
				var html = '';
				for(var i  in  msg.data){
					html +='<div class="txt1">';
					html +='<div class="pa5anr"><small  class="smallone"><{:date("Y-m-d H:i:s",$value['createtime'])}></small></div>';
					html +='<div class="pa5h4"style=" height: 15px;">'+msg.data[i].title+'</div>';
					html +='<div class="anniu">';
					html +='<font color="#fff">';
					html +='<b><a href="/index.php/Home/Article/article_detail/aid/'+msg.data[i].id+'.html" style="color:#ffffff">修改</a></b>';
					html +='</font>';
					html +='</div>';
					html +='<div class="anniu">';
					html +='<font color="#fff">';
					html +='<b>';
					html +='<a href="javascript:void(0)" data-aid="'+msg.data[i].id+'" onclick="delete_article(this)" style="color:#ffffff">删除</a>';
					html +='</b>';
					html +='</font>';
					html +='</div>';
					html +='</div>';
					html +='<hr class="hrrr"/>';
				}
				page = parseInt(page) + 1;
				$('#page').val(page);
				$('#loadding').before(html);
				layer.closeAll(); //关闭进度条
			}else{
				$('#page').val('-1');
				layer.closeAll(); //关闭进度条
			}
		}
	});
}

	//删除文章
	function delete_article(obj){
		var aid = $(obj).attr('data-aid');
			
		layer.open({
			content: '您确定删除文章吗？',
			btn: ['确认', '取消'],
			shadeClose: false,
			yes: function(){
				$.ajax({
					type: "POST",
					url: "<{:U('Home/Article/article_delete')}>",
					data: "aid="+aid,
					success: function(msg){
						if(msg.status == '-1' ){
							layer.open({
								content:msg.msg
							});
						}else{
							layer.open({
								content:'文章删除成功',
								btn: ['确认'],
								yes:function(){
								   window.location.reload();
								}
							});
						}
					}
				});
			}
		});	
	}
	
</script>
